package com.ylsd.prospectivestudent.controller;

import com.ylsd.prospectivestudent.entity.Clue;
import com.ylsd.prospectivestudent.service.ClueService;
import org.springframework.web.bind.annotation.*;
import org.ylsdxy.model.response.CustomPage;
import org.ylsdxy.model.response.ResponseResult;

import javax.annotation.Resource;
import java.util.List;
/*
* 线索
* */
@RestController
@RequestMapping("/prospectiveStudent")
public class ClueController {
    @Resource
    private ClueService clueService;

    @PostMapping("/findByCluePage/{id}")
    public ResponseResult<List<Clue>> findByCluePage(@PathVariable Integer id){
        return new ResponseResult<>(ResponseResult.SUCCESS,"success",clueService.findByPage(id));
    }
    @PostMapping("/insertClue")
    public ResponseResult<Boolean> insertClue(@RequestBody Clue clue){
        boolean result = clueService.insertClue(clue);
        if (result){
            return new ResponseResult<>(ResponseResult.SUCCESS,"success",true);
        }else {
            return new ResponseResult<>(ResponseResult.SYSTEM_ERROR,"error",null);
        }
    }

    @DeleteMapping("/delClue/{id}")
    public ResponseResult<Boolean> delClue(@PathVariable Integer id){
        boolean result = clueService.delClue(id);
        if (result){
            return new ResponseResult<>(ResponseResult.SUCCESS,"success",true);
        }else {
            return new ResponseResult<>(ResponseResult.SYSTEM_ERROR,"error",null);
        }
    }

    @PostMapping("/findByClue")
    public ResponseResult<List<Clue>> findByClue(@RequestBody Clue clue){
        return new ResponseResult<>(ResponseResult.SUCCESS,"success",clueService.findByClue(clue));
    }

}
